package com.qezhhnjy.cloud.zk.curator;

import lombok.extern.slf4j.Slf4j;
import org.apache.curator.framework.CuratorFramework;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author zhaoyangfu - 2020/8/19 16:09
 */
@SpringBootApplication
@Slf4j
public class ZkCuratorApp implements CommandLineRunner {

    @Resource
    private CuratorFramework zkClient;

    public static void main(String[] args) {
        SpringApplication.run(ZkCuratorApp.class, args);
    }

    @Override
    public void run(String... args) throws Exception {
        zkClient.create().forPath("/first");
        zkClient.create().forPath("/second");
        List<String> children = zkClient.getChildren().forPath("/");
        log.info(String.valueOf(children));
    }
}
